package com.cn.qtms.entity;//类注释设置模板

import com.cn.qtms.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Name:TmOrder
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-12-25 19:07
 **/
@Entity
@Table(name = "tm_order")
@org.hibernate.annotations.Table(appliesTo = "tm_order",comment="订单信息表")
@Getter
@Setter
public class TmOrder extends BaseEntity {

    private static final long serialVersionUID = 1L;


    @Column(name = "order_no",unique = true,columnDefinition = "varchar(50) COMMENT '订单号'")
    private String orderNo;


    @Column(name = "status", columnDefinition = "char(1) default '0' COMMENT '状态:0 已取消1已下单2已支付3已完成'")
    private String status;

    @Column(name = "order_time", columnDefinition = "datetime COMMENT '下单时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date orderTime;


    @Column(name = "remark", columnDefinition = "varchar(255) COMMENT '备注'")
    private String remark;

    /**
     * 用户标识
     */
    @Column(name = "user_id", columnDefinition = "bigint(20) comment '用户id'")
    @ApiModelProperty(value = "用户id")
    private Long userId;


    @Column(name = "total_points", columnDefinition = "int COMMENT '订单总额'")
    private Integer totalPoints;

    @Column(name = "actual_points", columnDefinition = "int COMMENT '实付金额'")
    private Integer actualPoints;



    @Column(name = "pay_time", columnDefinition = "datetime COMMENT '支付时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    private Date payTime;

    @Column(name = "goods_id", columnDefinition = "bigint(20) COMMENT '商品id'")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long goodsId;

    @OneToOne(mappedBy = "tmOrder")
    private TmOrderDetail tmOrderDetail;

}
